package com.sky.controller.user;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import com.sky.result.Result;
import com.sky.vo.DishVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Title: ShopController
 * @Author 贾金博
 * @Package com.sky.controller.admin
 * @Date 2024/3/27 21:48
 * @description: 用户端店铺的状态
 */

@RestController("adminShopController") // 指定bean的名字
@RequestMapping("/user/shop")
@Api("店铺相关接口")
@Slf4j

public class ShopController { // 不改名字的话 会发生Bean冲突

    @Autowired
    private RedisTemplate redisTemplate;


    /**
     * 获取店铺状态
     * @return
     */
    @GetMapping("/status")
    @ApiOperation("获取店铺状态")
    public Result<Integer> getStatus() {
        Integer shop_status = (Integer) redisTemplate.opsForValue().get("SHOP_STATUS");
        log.info("获取店铺状态: {}", shop_status == 1 ? "营业中" : "打烊中");
        return Result.success(shop_status);
    }

}
